#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>
#include <stdlib.h>

int main()
{
	//fclose(stdout);
	FILE* pf = fopen("text.txt", "w+");
	if (pf == NULL)
	{
		perror("text.txt");
		exit(EXIT_FAILURE);
	}

	fputc('h', pf);
	rewind(pf);
	char ch = fgetc(pf);
	fprintf(stdout, "%c\n", ch);

	fputs("hello", pf);
	fseek(pf, 1, SEEK_SET);
	char str[10] = { 0 };
	fgets(str, 9, pf);
	fprintf(stdout, "%s\n", str);

	long position = ftell(pf);
	
	if (feof(pf))
	{
		printf("hahah");
	}

	fclose(pf);
	

	return 0;
}